package com.example.zyl.inwatchapp;

import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.tencent.tws.widget.BaseActivity;
import com.tencent.tws.widget.TwsToast;

public class MainActivity extends BaseActivity {
    Button mButton0, mButton1, mButton2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mButton0 = (Button) findViewById(R.id.test0);
        mButton0.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                TwsToast.makeText(getApplicationContext(), "LONG TwsToast", Toast.LENGTH_LONG).show();
                // TwsToast mTwsToast = new TwsToast(getApplicationContext());
                // mTwsToast.setGravity(Gravity.FILL_HORIZONTAL | Gravity.CENTER_VERTICAL, 0, 80);
                // mTwsToast.setText("LONG TwsToast");
                // mTwsToast.setTextSize(24);
                // mTwsToast.setToastBackgroundColor(Color.YELLOW);
                // mTwsToast.setToastBackground(R.drawable.test_128x128);
                // mTwsToast.setDuration(TwsToast.LENGTH_LONG);
                // mTwsToast.show();
            }
        });

        mButton1 = (Button) findViewById(R.id.test1);
        mButton1.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                TwsToast mTwsToast = new TwsToast(getApplicationContext());
                mTwsToast.setGravity(Gravity.FILL_HORIZONTAL | Gravity.CLIP_VERTICAL, 0, 30);
                mTwsToast.setText("SHORT TwsToast");
                mTwsToast.setTextSize(24);
                mTwsToast.setToastBackgroundColor(Color.YELLOW);
                // mTwsToast.setToastBackground(R.drawable.test_128x128);
                mTwsToast.setDuration(TwsToast.LENGTH_SHORT);
                mTwsToast.show();
            }
        });

//        mButton2 = (Button) findViewById(R.id.test2);
//        mButton2.setOnClickListener(new View.OnClickListener() {
//
//            @Override
//            public void onClick(View v) {
//                // TODO Auto-generated method stub
//                // Toast.makeText(getApplicationContext(), "System Toast.", Toast.LENGTH_SHORT).show();
//                LayoutInflater inflater = getLayoutInflater();
//
//                View layout = inflater.inflate(R.layout.custom_toast,
//                        (ViewGroup) findViewById(R.id.custom_toast_layout_id));
//
//                // set a dummy image
//                ImageView image = (ImageView) layout.findViewById(R.id.image);
//                image.setImageResource(R.drawable.ic_launcher);
//
//                // set a message
//                TextView text = (TextView) layout.findViewById(R.id.text);
//                text.setText("Custom TwsToast");
//
//                // Toast...
//                TwsToast toast = new TwsToast(getApplicationContext());
//                toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
//                toast.setDuration(Toast.LENGTH_LONG);
//                toast.setView(layout);
//                toast.show();
//            }
//        });
    }
}
